<extend name="Public:mainbase" />
<block name="content">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/dhtmlxtree.css"/>
<script language="javascript" src="__PUBLIC__/js/member.js?{:time()}"></script>  
<script language="javascript" src="__PUBLIC__/js/Validform_v5.3.2_min.js?{:time()}"></script>
<link rel="stylesheet" href="__PUBLIC__/bootstrap-switch/bootstrap-switch.min.css">
<script src="__PUBLIC__/bootstrap-switch/bootstrap-switch.min.js"></script>
<style type="text/css">
	.Validform_checktip{line-height: 34px}
</style> 
<!--  内容列表   -->
<form name="form2" method="post">
<table width="98%" class="table table-bordered  table-hover table-condensed "  align="center">
<tr bgcolor="#E7E7E7" >
	<td height="28" colspan="10" background="__PUBLIC__/images/tbg.gif" style="padding-left:10px;">
	◆ 前台栏目列表 &nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-xs btn-warning" data-toggle="modal" data-target=".newcategorybox"><i class="glyphicon glyphicon-plus"></i> 添加栏目</button>
	</td>
</tr>
<tr align="center" bgcolor="#FBFCE2" height="25">
	<td width="6%">ID</td>
	<td width="4%">选择</td>
	<!--<td width="10%">栏目图标</td>-->
	<td width="10%">栏目标题</td>
	<td width="10%">栏目状态</td>
	<td width="10%">是否显示标题</td>
	<td width="10%">是否显示更多</td>
	<td width="10%">栏目类型</td>
	<td width="10%">排序</td>
	<td width="10%">创建时间</td>
	<td width="10%">操作</td>
</tr>
<foreach name="categoryList" item="val">
<tr align='center' valign="center" bgcolor="#FFFFFF" height="26">
	<td nowrap>{$val.id}</td>
	<td>
		<input name="id" type="checkbox" value="{$val.id}" class="np" />
	</td>
	<!--<td><?php if($val['image_url']) { ?><img src="{$val.image_url}?/imageView2/2/w/160/h/90"><?php } ?></td>-->
	<td><a href="{:U('manageCategoryContent')}?cid={$val.id}&ctype={$val.category_type}" data-id='{$val.id}' class='managecategorycontent'>{$val.name}</a></td>
	<td>
		<input type="checkbox" data-cid="{$val.id}" data-size="mini" data-animate="false" data-on-text="显示" data-off-text="隐藏" data-on-color="info" class="mySwitch switchStatus" <?php echo $val['status'] ? 'checked' : '' ?>>
	</td>
	<td>
		<input type="checkbox" data-cid="{$val.id}" data-size="mini" data-animate="false" data-on-text="显示" data-off-text="隐藏" data-on-color="info" class="mySwitch switchShowTitle" <?php echo $val['is_category_show'] ? 'checked' : '' ?> />
	</td>
	<td>
		<input type="checkbox" data-cid="{$val.id}" data-size="mini" data-animate="false" data-on-text="显示" data-off-text="隐藏" data-on-color="info" class="mySwitch switchShowMore" <?php echo $val['is_category_more'] ? 'checked' : '' ?> />
	</td>
	<td>{$val.category_type}</td>		
	<td>{$val.sort}</td>	
	<td>{$val.create_time|myDate="Y-m-d H:i",###}</td>
	<td>
		<a href="javascript:;" data-id='{$val.id}' class='editcategory'>编辑</a>
		|
		<?php if($val['category_type'] == 'live') { ?>
		<a href="{:U('getLiveList')}?cid={$val.id}" class='addcategorycontent'>添加内容</a>
		<?php } elseif($val['category_type'] == 'recommend') { ?>
		<a href="{:U('getCommonList')}?cid={$val.id}" class='addcategorycontent'>添加内容</a>
		<?php } elseif($val['category_type'] == 'slider') { ?>
		<a href="{:U('getCommonList')}?cid={$val.id}&c_type={$val.category_type}" class='addcategorycontent'>添加内容</a>
		<?php } elseif($val['category_type'] == 'special') { ?>
		<a href="{:U('getSpecialList')}?cid={$val.id}" class='addcategorycontent'>添加内容</a>
        <?php } elseif($val['category_type'] == 'author') { ?>
        <a href="{:U('getAuthorList')}?cid={$val.id}" class='addcategorycontent'>添加内容</a>
        <?php } ?>
		|
		<a href="javascript:;" data-id='{$val.id}' class='delcategory'>删除</a>
	</td>
</tr>
</foreach>
<tr bgcolor="#ffffff">
<td height="36" colspan="10">
	&nbsp;
	<a href="javascript:selAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-ok'></i> 全选</a>
	<a href="javascript:noSelAll()" class="btn btn-xs btn-info"><i class='glyphicon glyphicon-remove'></i> 取消</a>
	<!-- <a href="javascript:checkArc(0)" class="btn btn-xs btn-info">&nbsp;审核&nbsp;</a> -->
	<a href="javascript:;" id="delcategoryall" class="btn btn-xs btn-info"><i class="glyphicon glyphicon-trash"></i> 删除</a>
</td>
</tr>
</form>
<tr align="right" bgcolor="#F9FCEF">
	<td height="36" colspan="10" align="center">
		<div class='page'>{$showpage}</div>
	</td>
</tr>
</table>

<!--  搜索表单  -->
<form name='form3' action='' method='get'>
<input type='hidden' name='dopost' value='listArchives' />
<table width='98%'  class='table' align="center" style="margin-top:8px">
  <tr bgcolor='#EEF4EA'>
    <td background='__PUBLIC__/images/wbg.gif' align='center'>
      <table border='0' cellpadding='0' cellspacing='0' height="32">
        <td nowrap>栏目名称：</td>
        <td width='130'>
          	<input type='text' name='name' value='' style='width:120px' />
        </td>
       <td>
          <input name="imageField" type="image" src="__PUBLIC__/images/button_search.gif" width="60" height="22" border="0" class="np" />
       </td>
      </tr>
     </table>
   </td>
  </tr>
</table>
</form>


<!-- 添加分类弹窗 -->
<div class="modal fade newcategorybox" tabindex="-1" Auth="dialog" aria-labelledby="add_user_jump" id='newcategorybox'>
  <div class="modal-dialog modal-sm" style="width:40%">
  		
    <div class="modal-content">
		<div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title">添加栏目信息</h4>
	    </div>
		<form action="{:U('addCategory')}" method="POST" class="form-horizontal" id="addcategoryform" style="padding:15px 0" enctype="multipart/form-data">
		<div class="form-group">
			<label for="name" class="col-sm-2 control-label">栏目名称</label>
			<div class="col-sm-5">
				<input name="name" id="name" type="text" placeholder="请输入栏目名称" datatype="*2-30" sucmsg=" " errormsg="用户名为2-30个字符" nullmsg="栏目名称必须填写" class="form-control" value="">
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="status" class="col-sm-2 control-label">状态</label>
			<div class="col-sm-5">
				<select name="status" id="status"  class="form-control" datatype="*" nullmsg='请选择状态' sucmsg=" ">
					<option value="1">使用中</option>
					<option value="0">已冻结</option>
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="is_category_show" class="col-sm-2 control-label">是否显示</label>
			<div class="col-sm-5">
				<select name="is_category_show" id="is_category_show" class="form-control" datatype="*" nullmsg='请选择是否显示' sucmsg=" ">
					<option value="1">是</option>
					<option value="0">否</option>
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="is_category_more" class="col-sm-2 control-label">是否显示更多</label>
			<div class="col-sm-5">
				<select name="is_category_more" id="is_category_more" class="form-control" datatype="*" nullmsg='请选择是否显示更多' sucmsg=" ">
					<option value="1">是</option>
					<option value="0">否</option>
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="category_type" class="col-sm-2 control-label">栏目类型</label>
			<div class="col-sm-5">
				<select name="category_type" id="category_type" class="form-control" datatype="*" nullmsg='请选择栏目类型' sucmsg=" ">
					<?php foreach($typeList as $val) { ?>
					<option value="<?php echo $val['id']; ?>"><?php echo $val['category_type']; ?></option>
					<?php } ?>	
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="sort" class="col-sm-2 control-label">排序</label>
			<div class="col-sm-5">
				<input name="sort" id="sort" type="text" placeholder="请输入排序"  class="form-control" value="0">
			</div>
			<div class="col-sm-5"></div>
		</div>

		<!--<div class="form-group">
			<label for="image_url" class="col-sm-2 control-label">图标</label>
			<div class="col-sm-5">
				<input name="image_url" id="image_url" type="file" class="form-control" />
			</div>
			<div class="col-sm-5" id="show_image"></div>
		</div>-->

		<div class="add-error-message error item"></div>

		<div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="submit" class="btn btn-success">确定添加</button>
		      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		      <button type="button" class="btn btn-danger"  data-dismiss="modal">取消</button>
		    </div>
		  </div>
		</form>
    </div>
  </div>
</div>

<!-- 修改分类弹窗 -->
<div class="modal fade editcategorybox" tabindex="-1" Auth="dialog" aria-labelledby="add_user_jump" id='editcategorybox'>
  <div class="modal-dialog modal-sm" style="width:40%">
  		
    <div class="modal-content">
		<div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title">添加栏目信息</h4>
	    </div>
		<form action="{:U('editCategory')}" method="POST" class="form-horizontal" id="editcategoryform" style="padding:15px 0" enctype="multipart/form-data">
		<input name='id' type="hidden" value=''>
		<div class="form-group">
			<label for="name" class="col-sm-2 control-label">栏目名称</label>
			<div class="col-sm-5">
				<input name="name" type="text" placeholder="请输入栏目名称" datatype="*2-30" sucmsg=" " errormsg="用户名为2-30个字符" nullmsg="栏目名称必须填写" class="form-control" value="">
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="status" class="col-sm-2 control-label">状态</label>
			<div class="col-sm-5">
				<select name="status" class="form-control" datatype="*" nullmsg='请选择状态' sucmsg=" ">
					<option value="1">使用中</option>
					<option value="0">已冻结</option>
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="is_category_show" class="col-sm-2 control-label">是否显示</label>
			<div class="col-sm-5">
				<select name="is_category_show" class="form-control" datatype="*" nullmsg='请选择是否显示' sucmsg=" ">
					<option value="1">是</option>
					<option value="0">否</option>
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="is_category_more" class="col-sm-2 control-label">是否显示更多</label>
			<div class="col-sm-5">
				<select name="is_category_more" class="form-control" datatype="*" nullmsg='请选择是否显示更多' sucmsg=" ">
					<option value="1">是</option>
					<option value="0">否</option>
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="category_type" class="col-sm-2 control-label">栏目类型</label>
			<div class="col-sm-5">
				<select name="category_type" class="form-control" datatype="*" nullmsg='请选择栏目类型' sucmsg=" ">
					<?php foreach($typeList as $val) { ?>
					<option value="<?php echo $val['id']; ?>"><?php echo $val['category_type']; ?></option>
					<?php } ?>	
				</select>
			</div>
			<div class="col-sm-5"></div>
		</div>

		<div class="form-group">
			<label for="sort" class="col-sm-2 control-label">排序</label>
			<div class="col-sm-5">
				<input name="sort" type="text" placeholder="请输入排序"  class="form-control" value="0">
			</div>
			<div class="col-sm-5"></div>
		</div>

		<!--<div class="form-group">
			<label for="image_url" class="col-sm-2 control-label">图标</label>
			<div class="col-sm-5">
				<input name="image_url" type="file" class="form-control" />
			</div>
			<div class="col-sm-5" id="show_image"></div>
		</div>-->

		<div class="add-error-message error item"></div>

		<div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="submit" class="btn btn-success">确定修改</button>
		      <button type="button" class="btn btn-danger"  data-dismiss="modal">取消</button>
		    </div>
		  </div>
		</form>
    </div>
  </div>
</div>



<script src="__PUBLIC__/js/dhtmlxtree.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/lang/zh-cn/zh-cn.js"></script>
<style type="text/css">
.editarticlebox { z-index: 900 !important; }
.modal-backdrop	{z-index: 800 !important; }
</style>
<script type="text/javascript">
	$(".mySwitch").bootstrapSwitch();
	$('.delcategory').click(function(){
		if(confirm('是否确定删除此栏目？')){
			var obj=this;
			$.get('{:U("ajaxDelCategory")}?id='+$(obj).data('id'),function(data){
				if(data.status==1){
					$(obj).parents('tr').remove();
				}
			})
		}
	})

	$('#delcategoryall').click(function(){
		if(confirm('是否确定删除？')){
			var id=$('[name=id]:checked').map(function(){
				return $(this).val();
			}).get().join()
			
			$.get('{:U("ajaxDelCategory")}?id='+id,function(data){
				if(data.status==1){
					$('[name=id]:checked').parents('tr').remove();
				}
			})
		}
	})

	$('.editcategory').click(function(){
		$('#editcategorybox form').get(0).reset();
		$.get("{:U('ajaxGetCategoryInfo')}?id="+$(this).data('id'),function(data){
  			if(data!=0){
  				$("#editcategorybox [name=id]").val(data.id);
  				$("#editcategorybox [name=name]").val(data.name);
  				$("#editcategorybox [name=status]").val(data.status);
  				$("#editcategorybox [name=is_category_show]").val(data.is_category_show);
  				$("#editcategorybox [name=is_category_more]").val(data.is_category_more);	
  				$("#editcategorybox [name=category_type]").val(data.category_type);	
  				$("#editcategorybox [name=sort]").val(data['sort']);	
  				$("#editcategorybox [id=show_image]").html('<img src="/Html/Uploads/' + data.image_url + '" width="50" height="50" />');		
  			}
  		})
		$('#editcategorybox').modal('show');
	})

	function selAll(){
		$('[name=id]').each(function(){
			this.checked=true;
		})
	}
	function noSelAll(){
		$('[name=id]').each(function(){
			this.checked=false;
		})
	}

	$('.addcategorycontent').click(function () {

		$('#addcategorycontentbox').modal('show');
	})


	$('.switchStatus').on('switchChange.bootstrapSwitch', function(event, state) {
		var cid=$(this).data('cid');
        state=state?1:0;
		$.getJSON('{:ajaxSetStatus}',{cid:cid,state:state},function (data) {
			if(data.resultCode!=0){
				alert(data.info);
				$(this).bootstrapSwitch('toggleState');
			}
		})
	});

    $('.switchShowTitle').on('switchChange.bootstrapSwitch', function(event, state) {
        var cid=$(this).data('cid');
        state=state?1:0;
        $.getJSON('{:ajaxSetShowTitle}',{cid:cid,state:state},function (data) {
            if(data.resultCode!=0){
                alert(data.info);
                $(this).bootstrapSwitch('toggleState');
            }
        })
    });

    $('.switchShowMore').on('switchChange.bootstrapSwitch', function(event, state) {
        var cid=$(this).data('cid');
        state=state?1:0;
        $.getJSON('{:ajaxSetShowMore}',{cid:cid,state:state},function (data) {
            if(data.resultCode!=0){
                alert(data.info);
                $(this).bootstrapSwitch('toggleState');
            }
        })
    });

</script>

</block>